package com.oj.common;

import com.oj.common.constants.ApiGwConstant;
import com.oj.common.domain.BaseInfo;
import com.oj.common.exception.BreezeeException;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 更新的服务接口
 * Created by Silence on 2017/12/13.
 */
public interface ICrudService<T extends BaseInfo> {

    /**
     * 保存指定的对象
     *
     * @param t 对象信息
     * @return 保存后的对象
     * @throws BreezeeException 异常信息
     */
    @PutMapping(value = ApiGwConstant.SAVE_METHOD)
    T saveInfo(T t) throws BreezeeException;

    @GetMapping(value = ApiGwConstant.ID_METHOD)
    T findInfoById(@PathVariable("id") String id) throws BreezeeException;

    @PostMapping(value = ApiGwConstant.LIST_METHOD)
    List<T> listInfos(T t);

    @PostMapping(value = ApiGwConstant.PAGE_METHOD)
    InfoPage<T> pageInfos(T t);

    @DeleteMapping(value = ApiGwConstant.ID_METHOD)
    void deleteInfo(@PathVariable("id") String id) throws BreezeeException;
}
